package com.execdemo.demoeventservice.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.execdemo.demoeventservice.domain.Eventlist;
import com.execdemo.demoeventservice.service.EventlistService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/event")
public class EventController {

    @Autowired
    private EventlistService eventlistService;

    @GetMapping("/getEventByCode/{code}")
    public Eventlist getStoreByCode(@PathVariable("code") String code) {

        Eventlist eventlist = eventlistService.getOne(new LambdaQueryWrapper<Eventlist>().eq(Eventlist::getCode, code));
        log.info("查询结果：{}", JSON.toJSONString(eventlist));
        return eventlist;

    }
}
